package com.clothing.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.clothing.dao.CommentReplyDao;
import com.clothing.dao.MessageDao;
import com.clothing.entity.CommentReply;
import com.clothing.entity.Message;
import com.clothing.service.CommentReplyService;
import com.clothing.utils.page.Page;
import com.clothing.utils.page.Pageable;

/**
 * @ClassName: CommentServiceImpl 
 * @Description: TODO(Service) 
 * @author Charles.Tao 
 * @date 2017年9月6日 下午3:43:34 
 * @version 1.0
 */
@Service
public class CommentReplyServiceImpl extends BaseServiceImpl<CommentReply, Long> implements CommentReplyService
{
    @Autowired
    private CommentReplyDao commentReplyDao;
    
    @Autowired
    private MessageDao messageDao;
    
    @Override
    public void reply(CommentReply commentReply)
    {
        commentReplyDao.persist(commentReply);
        Message message = new Message();
        message.setContent(commentReply.getContent());
        message.setSender(commentReply.getCreator());
        message.setReceiver(commentReply.getOther());
        message.setType(Message.Type.reply);
        message.setFkId(commentReply.getComment().getId());
        messageDao.persist(message);
    }

    @Override
    public Page<CommentReply> myCommentList(Long userId, Pageable pageable)
    {
        return commentReplyDao.myCommentList(userId, pageable);
    }
}
